<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // console.log(1);
    // console.log(a);
    // console.log(2);
    // 错误 捕获  
    /* try{
      console.log(1);
    }catch(err){
      console.log(err);
      console.log('错误后执行这个');
    }

    console.log(2); */

    // e.cancelBubble = true
    /* if (e.stopPropgation){
      e.stopPropgation();
    }else{
      e.cancelBubble = true
    }

    try{
      e.stopPropgation();
    }catch(err){
      e.cancelBubble = true
    } */

    // 自定义错误
    
    const fn = (n) => {
      // 必须是number 
      if (typeof n !== 'number') {
        // 报错
        // 自定义错误
        const  err = new Error('参数必须是number');
        // 抛出错误
        throw(err);
      }
    }
    fn('11')
    console.log(22);
  </script>
</body>
</html>